<template>
    <div class="row">
        <div class="col-lg-12" v-show="info.isFirst">
            <h2>Welcome to use!</h2>
        </div>
        <div class="col-lg-12" v-show="info.loading">
            <h2>loading...</h2>
        </div>
        <div class="col-lg-12" v-show="info.errMsg">
            <h2>{{ info.errMsg }}</h2>
        </div>

        <div v-show="info.userList.length > 0" class="card" v-for="user in info.userList" :key="user.id">
            <a :href="user.html_url" target="_blank">
                <img :src="user.avatar_url" style='width: 100px'/>
            </a>
            <p class="card-text">{{user.login}}</p>
        </div>
    </div>
</template>

<script>

import pubsub from "pubsub-js";
export default {
    name: 'List',
    data(){
        return {
            info: {
                userList: [],
                loading: false,
                errMsg: null,
                isFirst: true
            }
        }
    },
    mounted(){
        pubsub.subscribe('search', (search, info) => {
            this.info = info;
        });

    }
}

</script>
<style scoped>

</style>
